<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/2/16
 * Time: 9:57
 */

namespace Admin\Controller;


class FuturesTypeController extends AdminController
{   
    /**
     * [index 期货类型列表]
     * @return [type] [description]
     */
    public function index(){
        $list = M('FuturesType')->select();
        $this->assign('_list',$list);
        $this->display();
    }

    /**
     * [add 新增类型]
     */
    public function add(){
        if(IS_POST){
            $name = I('post.name');
            if(empty($name)) $this->error('名称不能为空!');
            $sign = I('post.sgin');
            if(empty($sign)) $this->error('标识不能为空!');
            $status = I('post.status');
            $data['name'] = $name;
            $data['sign'] = $sign;
            $data['status'] = $status;
            $data['adm_id'] = session('user_auth.uid');
            $data['create_time'] = time();
            $res = M('FuturesType')->add($data);
            if(false!==$res){
                $this->success('新增成功');
            }else{
                $this->error('新增失败');
            }
        }
        $this->display();
    }

    public function addType(){
        if(IS_POST){
            $name = I('post.name');
            if(empty($name)) $this->error('名称不能为空!');
            $sign = I('post.sign');
            if(empty($sign)) $this->error('标识不能为空!');
            $status = I('post.status');
            $data['name'] = $name;
            $data['sign'] = $sign;
            $data['status'] = $status;
            $data['adm_id'] = session('user_auth.uid');
            $data['create_time'] = time();
            $res = M('FuturesType')->add($data);
            if(false!==$res){
                $this->success('新增成功');
            }else{
                $this->error('新增失败');
            }
        }
        $this->display('add');
    }

    /**
     * [edit 编辑类型]
     * @return [type] [description]
     */
    public function edit(){
        $this->display();
    }

}